package cn.itcast.user.service.impl;

import cn.itcast.hmall.dto.common.ThreadLocalUtil;
import cn.itcast.hmall.pojo.user.Address;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.itcast.user.service.AddressService;
import cn.itcast.user.mapper.AddressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author T50
* @description 针对表【tb_address】的数据库操作Service实现
* @createDate 2022-06-22 13:28:36
*/
@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address>
    implements AddressService{
    @Autowired
    private AddressMapper addressMapper;
    @Override
    public List<cn.itcast.hmall.pojo.user.Address> findUserById() {
        Long userId = ThreadLocalUtil.getUserId();
        LambdaQueryWrapper<Address> query = Wrappers.lambdaQuery();
        query.eq(Address::getUserId,userId);
        List<Address> list = addressMapper.selectList(query);
        return list;
    }

    @Override
    public Address findByAddressId(String id) {
        return addressMapper.selectById(id);
    }

}




